﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OptixDotNet;
using Buffer = OptixDotNet.Buffer;

namespace RayDen.Optix.Engine.Managers
{
    public class OptixResourceManager : IDisposable
    {

        private List<IDisposable> resources;

        public OptixResourceManager()
        {
            resources = new List<IDisposable>();
        }


        public Buffer CreateBuffer(Context ctx, BufferDesc desc)
        {
            var result = new Buffer(ctx, desc);
            resources.Add(result);
            return result;
        }


        public void Dispose()
        {
            foreach (var disposable in resources)
            {
                if (disposable != null)
                    disposable.Dispose();
            }
        }
    }
}
